Make network-bridge fail on NFS or iscsi root.
authorKeir Fraser <keir@xensource.com>
Sun, 1 Jul 2007 21:20:46 +0000 (22:20 +0100)
committerKeir Fraser <keir@xensource.com>
Sun, 1 Jul 2007 21:20:46 +0000 (22:20 +0100)
Since setting up bridging involves bringing down the network interface,
bridging clearly isn't compatible with the likes of NFS or iSCSI root.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
tools/examples/network-bridge

index a7ee9067be67ab1a805dd9c4ee7d3978cf3d8aac..6b528d8a48078694809e9f68900a7e060dd46102 100755 (executable)
@@ -172,11 +172,23 @@ show_status () {
     echo '============================================================'
 }
 
+is_network_root () {
+    local rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $3; }}' /etc/mtab)
+    local rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' /etc/mtab)
+
+    [[ "$rootfs" =~ "^nfs" ]] || [[ "$rootopts" =~ "_netdev" ]] && return 0 || return 1
+}
+
 op_start () {
     if [ "${bridge}" = "null" ] ; then
        return
     fi
 
+    if is_network_root ; then
+        [ -x /usr/bin/logger ] && /usr/bin/logger "network-bridge: bridging not supported on network root; not starting"
+        return
+    fi
+
     if link_exists "$pdev"; then
         # The device is already up.
         return